<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions" 
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <ui:composition>
        <style type="text/css">
            .gridStyle{
                margin:10px 10px 10px 0px;
            }
            .top{
                vertical-align: top;
            }
        </style>
        <h:form id="personInformation">
            <rich:panel header="人员信息" id="ipanel" styleClass="content-hight">
                <rich:messages/>
                <rich:toolbar id="tolbar1">
                    <rich:toolbarGroup>
                        <a4j:commandButton value="新增" execute="@this" render="deptcode,tolbar1,maininfo"
                                           action="#{personBean.add}" immediate="true">
                        </a4j:commandButton>
                        <a4j:commandButton value="修改" execute="@this" render="ipanel"
                                           action="#{personBean.update}"
                                           disabled="#{personBean.addOrUpdate or
                                                       empty personBean.person}">
                        </a4j:commandButton>
                        <a4j:commandButton value="保存" render="ipanel"
                                           action="#{personBean.save}"
                                           disabled="#{!personBean.editStatus}">
                        </a4j:commandButton>
                        <a4j:commandButton value="删除" execute="@this" render="ipanel"
                                           action="#{personBean.delete}"
                                           disabled="#{personBean.addOrUpdate or
                                                       empty personBean.person}">
                        </a4j:commandButton>
                        <a4j:commandButton value="取消" execute="@this" render="ipanel"
                                           action="#{personBean.cancel}"/>
                    </rich:toolbarGroup>
                </rich:toolbar>
                <h:panelGrid columns="2" width="100%" border="0" id="mainform"  rowClasses="treeRow" columnClasses="top,top">
                    <h:panelGroup>
                        <rich:tree value="#{departmentBean.rootNode}" var="idept"
                                   selectionType="ajax" toggleType="client"
                                   selectionChangeListener="#{personBean.treeSelected}"
                                   style="width:300px" render="tableGroup,maininfo,tolbar1">
                            <rich:treeNode>
                                <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                            </rich:treeNode>
                        </rich:tree>
                    </h:panelGroup>
                    <h:panelGroup>

                        <h:outputLabel id="errmessage" value="#{queryBean.err.errtip}" style="color:red" />

                        <h:panelGrid columns="4" id="maininfo" styleClass="gridStyle">
                            <h:outputText value="人员代码:"/>
                            <h:inputText  disabled="#{!personBean.editStatus || !personBean.addOrUpdate}" id="code"
                                          value="#{personBean.person.cpsn_number}" 
                                          required="true" requiredMessage="人员代码不能为空！"/>                        

                            <h:outputText value="人员姓名:"/>
                            <h:inputText  disabled="#{!personBean.editStatus}" id="name"
                                          value="#{personBean.person.cpsn_name}" 
                                          required="true" requiredMessage="人员姓名不能为空！"/>

                            <h:outputText value="身份证号:"/>
                            <h:inputText  disabled="#{!personBean.editStatus}" id="id"  value="#{personBean.person.id_No}" 
                                          required="false" requiredMessage="身份证号不能为空！"/>

                            <h:outputText value="银行账号:"/>
                            <h:inputText  disabled="#{!personBean.editStatus}"
                                          id="account" value="#{personBean.person.bankAccount}" 
                                          required="false" requiredMessage="银行账号不能为空！"/>

                            <h:outputText value="开户银行:"/>
                            <h:inputText  disabled="#{!personBean.editStatus}"
                                          id="bankAccount" value="#{personBean.person.bank}"
                                          required="false" requiredMessage="开户银行不能为空！"/>

                            <h:outputText value="公积金账号:"/>
                            <h:inputText  disabled="#{!personBean.editStatus}"
                                          id="gjjzh"  value="#{personBean.person.gjjzh}"
                                          required="false" requiredMessage="公积金账号不能为空！"/>

                            <h:outputText value="部门:"/>
                            <h:inputText disabled="#{!personBean.editStatus}"
                                         id="deptcode" readonly="true"
                                         value="#{personBean.person.deptName}"
                                         required="true" requiredMessage="部门代码不能为空！"/>

                            <h:outputText value="邮箱:"/>
                            <h:inputText  disabled="#{!personBean.editStatus}"
                                          id="email"  value="#{personBean.person.email}" 
                                          required="false" requiredMessage="邮箱不能为空！"/>

                            <h:outputText value="职务:"/>
                            <h:inputText  disabled="#{!personBean.editStatus}"
                                          id="duty"  value="#{personBean.person.duty}" 
                                          required="false" requiredMessage="职务不能为空！"/>

                            <h:outputText value="待遇级别:"/>
                            <h:inputText  disabled="#{!personBean.editStatus}"
                                          id="dealLevel"  value="#{personBean.person.dyjb}"
                                          required="false" requiredMessage="待遇级别不能为空！" />

                            <h:outputText value="权限:"/>
                            <h:selectOneMenu value="#{personBean.person.role}" id="role"
                                             disabled="#{!personBean.editStatus}"
                                             required="true" requiredMessage="请选择权限！">
                                <f:selectItem itemLabel="-请选择-"       itemValue=""/>
                                <f:selectItem itemLabel="普通用户"       itemValue="E"/>
                                <f:selectItem itemLabel="财务"           itemValue="C"/>
                                <f:selectItem itemLabel="出纳"           itemValue="P"/>
                                <f:selectItem itemLabel="系统管理员"     itemValue="A"/>
                            </h:selectOneMenu>
                        </h:panelGrid>
                    </h:panelGroup>
                </h:panelGrid>
                <h:panelGroup id="tableGroup">
                    <rich:dataScroller for="personinfo" execute="@this" render="tableGroup"/>
                    <div style="max-width: 800px;overflow:auto;">
                        <rich:dataTable  value="#{personBean.personModel}"
                                         var="person"
                                         style="width:100%;"
                                         rows="10"
                                         id="personinfo"
                                         styleClass="tableStyle"
                                         noDataLabel="无数据！">
                            <f:facet name="header">
                                <h:outputText value="部门人员信息" />
                            </f:facet>                    
                            <rich:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="人员代码"/>
                                    </h:panelGroup>
                                </f:facet>
                                <a4j:commandLink value="#{person.cpsn_number}"
                                                 action="#{personBean.personSelected}"
                                                 execute="@this"
                                                 render="tolbar1,maininfo"/>
                            </rich:column>
                            <rich:column >
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="人员姓名"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText  value="#{person.cpsn_name}" />
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="身份证号"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText  value="#{person.id_No}"/>
                            </rich:column>
                            <rich:column >
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="银行账号"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{person.bankAccount}"/>
                            </rich:column>
                            <rich:column >
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="开户银行"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{person.bank}"/>
                            </rich:column>
                            <rich:column >
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="公积金账号"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{person.gjjzh}"/>
                            </rich:column>
                            <rich:column >
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="所属部门"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{person.deptName}"/>
                            </rich:column>
                            <rich:column >
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="邮箱"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{person.email}"/>
                            </rich:column>
                            <rich:column >
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="权限"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="普通用户"       rendered="#{fn:trim(person.role) eq 'E'}"/>
                                <h:outputText value="部门负责人"     rendered="#{fn:trim(person.role) eq 'D'}"/>
                                <h:outputText value="管理员(资产)"   rendered="#{fn:trim(person.role) eq 'Z'}"/>
                                <h:outputText value="管理员(工会)"   rendered="#{fn:trim(person.role) eq 'H'}"/>
                                <h:outputText value="管理员(党委)"   rendered="#{fn:trim(person.role) eq 'P'}"/>
                                <h:outputText value="财务"           rendered="#{fn:trim(person.role) eq 'C'}"/>
                                <h:outputText value="系统管理员"     rendered="#{fn:trim(person.role) eq 'A'}"/>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">职务</f:facet>
                                <h:outputText value="#{person.duty}"/>
                            </rich:column>
                            <rich:column>
                                <f:facet name="header">待遇级别</f:facet>
                                <h:outputText value="#{person.dyjb}"/>
                            </rich:column>
                        </rich:dataTable>
                    </div>
                </h:panelGroup>
            </rich:panel>
        </h:form>
    </ui:composition>
</html>
